package cn.edu.sdu.sol.intake_system.controller;

import cn.edu.sdu.sol.intake_system.model.vo.DataRequest;
import cn.edu.sdu.sol.intake_system.model.vo.DataResponse;
import cn.edu.sdu.sol.intake_system.service.ImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/api/img")
public class ImageController {
    @Autowired
    ImgService imgService;

    @PostMapping("/uploadheadimg")
    public DataResponse uploadHeadImage(@RequestParam("file") MultipartFile file,
                                        @RequestParam("filename") String filename,
                                        @RequestHeader("Authorization") String token) {
        return imgService.uploadHeadImage(file, filename, token);
    }

    @PostMapping("/getheadimg")
    public DataResponse getHeadImage(@RequestHeader("Authorization") String token) {
        return imgService.getHeadImage(token);
    }


    @PostMapping("/getdepartmentimg")
    public DataResponse getDepartmentImage(@RequestHeader("Authorization") String token, @RequestBody DataRequest dataRequest) {
        return imgService.getDepartmentImage(token, dataRequest);
    }

    @PostMapping("/getalldepartmentimg")
    public DataResponse getAllDepartmentImg(@RequestHeader("Authorization") String token){
        return imgService.getAllDepartmentImg(token);
    }

}